﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Sharp_Explorer
{
    class FormClasses
    {
        private void AddComputer()
        {
            string newComputerName;
            using (ComputerIn newComputer = new ComputerIn())
            {
                newComputer.ShowDialog();
                newComputerName = newComputer.results;
            }
        }

        public static string getPathfromNode(TreeNode cNode)
        {
            string nodePath = cNode.FullPath.ToString();
            TreeNode saveNode = cNode;
            string adamNode = "";

            while (cNode.Parent != null)
            {
                cNode = cNode.Parent;
            }
            adamNode = cNode.Text.ToString();

            string goodPath = null;
            if (nodePath.Contains("My Computer"))
            {
                int lenRem = adamNode.Length;
                goodPath = nodePath.Remove(0, lenRem + 1);
            }
            else
            {
                goodPath = nodePath;
            }

            return goodPath;
        }

        public static string readFile(string Path)
        {
            string toReturn = string.Empty;
            try
            {
                if (File.Exists(Path))
                    toReturn = File.ReadAllText(Path, Encoding.Default);
            }
            catch (Exception err)
            {
                toReturn = err.Message;
                MessageBox.Show(err.Message);
                return toReturn;
            }
            return toReturn;
        }
    }
}
